package com.simple.framework.core.action.repository;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.simple.framework.core.action.Action;
import com.simple.framework.core.entry.ActionContext;
import com.simple.framework.core.entry.ActionResult;

/**
 * 日志方式记录事件执行信息
 * 
 * @author wujiangpo
 *
 */
public class LogActionRepository<R extends ActionResult, C extends ActionContext> implements ActionRepository<R, C> {

	Logger log = LoggerFactory.getLogger(getClass());

	@Override
	public void beforeActionProcess(Action<R, C> action, C actionContext) {
		log.info("主键{}执行事件{}开始...", actionContext.getKey(), action.bindActionName());
	}

	@Override
	public void afterActionProcess(Action<R, C> action, C actionContext) {
		log.info("主键{}执行事件{}结束。", actionContext.getKey(), action.bindActionName());
	}

	@Override
	public void afterActionProcessException(Action<R, C> action, C actionContext, Exception e) {
		log.error("主键{}执行事件{}执行异常！异常信息如下:", actionContext.getKey(), action.bindActionName(), e);
	}

}
